package sedev.shopping.util;

public class Paging {
	private Integer current;
	private Long totalRecord;
	private Integer pageSize;	
	private Integer numDisplay;
	
	public Paging(){
		current = 0;
		totalRecord = Long.valueOf(0);
		pageSize = 0;
	}
	
	public Integer getCurrent(){
		return this.current;		
	}	
	public void setCurrent(Integer current){
		this.current = current;		
	}
	
	public Long getTotalRecord(){
		return this.totalRecord;		
	}
	public void setTotalRecord(Long totalRecord){
		this.totalRecord = totalRecord;		
	}
		
	public Integer getPageSize(){
		return this.pageSize;		
	}
	public void setPageSize(Integer pageSize){
		this.pageSize = pageSize;		
	}
	
	public Integer getNumDisplay(){
		return this.numDisplay;		
	}
	public void setNumDisplay(Integer numDisplay){
		this.numDisplay = numDisplay;		
	}
	
	public void checkPage(){
		if (this.pageSize < 1)
			this.pageSize = 1;
		if (this.current < 1) {
			this.current = 1;
		} else {
			Long totalpage = (this.totalRecord / this.pageSize);			
			if((this.totalRecord % this.pageSize) > 0){
				totalpage += 1;
			}
			if (this.current > totalpage)
				this.current = totalpage.intValue();
		}
	}
}
